<?php
header("Content-Type: text/html");
header("charset: utf-8");
include_once("_common.php");

$sop = strtolower($sop);
if ($sop != "and" && $sop != "or")
    $sop = "and";

// 분류 선택 또는 검색어가 있다면
$stx = urldecode(trim($stx));


$table_gubun = "";
if($write_table == "g4_write_sellitem"){
	$table_gubun = "sellitem";
}
if($write_table == "g4_write_buyitem"){
	$table_gubun = "buyitem";
}

$board = sql_fetch(" select * from g4_board where bo_table = '$bo_table' ");

if ($sca || $stx || $bo_gubun)
{
    if($bo_gubun == "my_write"){
    	//내게시물의 글일경우 검색조건 추가 -> outlogin.skin.2.php
    	$sql_search = " mb_id = '$mb_id' and wr_is_comment = 0 ";
    } else if($bo_gubun == "member_write"){
    	//회원게시물의 글일경우 검색조건 추가 -> outlogin.skin.2.php
    	$sql_search = " mb_id = '$param_data' and wr_is_comment = 0 ";
    } else if($bo_gubun == "my_interest"){
    	//내관심상품의 글일경우 검색조건 추가 -> outlogin.skin.2.php
    	$sql_search = " wr_id in (select wr_id from g4_scrap where bo_table = '$write_table' and mb_id = '$mb_id') "; // and wr_9 != 'SELL' ";
    } else if($bo_gubun == "my_lounge"){
    	//즐겨찾기 라운지 글일경우 검색조건 추가
    	$sql_search = " wr_10 like '".urldecode($param_data)."%' "; // and wr_9 != 'SELL' ";
    } else if($bo_gubun == "my_sidoSearch"){
    	//시도 검색글일경우 검색조건 추가
    	$arr_sido = explode(",", urldecode($sidoStr));
    	$sql_search = "( ";
    	for($k=0; $k<count($arr_sido); $k++){
    		if(strrpos($arr_sido[$k], "|")){
    			$arr_gugun = explode("|", $arr_sido[$k]);
    			if($k < count($arr_sido) - 1){
    				if($arr_gugun[1] == "종중"){
    					$sql_search .= " ( wr_area like '%".$arr_gugun[0]."%' and (wr_area like '%종로%' or wr_area like '%중구%') ) or ";
    				}else{
    					$sql_search .= " ( wr_area like '%".$arr_gugun[0]."%' and wr_area like '%".$arr_gugun[1]."%' ) or ";
    				}
    			}else{
    				if($arr_gugun[1] == "종중"){
    					$sql_search .= " ( wr_area like '%".$arr_gugun[0]."%' and (wr_area like '%종로%' or wr_area like '%중구%') ) ) "; // and wr_9 != 'SELL' ";
    				}else{
    					$sql_search .= " ( wr_area like '%".$arr_gugun[0]."%' and wr_area like '%".$arr_gugun[1]."%' ) ) "; // and wr_9 != 'SELL' ";
    				}
    			}
    		}else{
    			if($k < count($arr_sido) - 1){
    				$sql_search .= " wr_area like '%".$arr_sido[$k]."%' or ";
    			}else{
    				$sql_search .= " wr_area like '%".$arr_sido[$k]."%' ) ";	// and wr_9 != 'SELL' ";
    			}
    		}
    	}
    } else{
    
	    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);
	
	    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)
	    $sql = " select MIN(wr_num) as min_wr_num from $write_table ";
	    $row = sql_fetch($sql);
	    $min_spt = $row[min_wr_num];
	
	    if (!$spt) $spt = $min_spt;
	
	    $sql_search .= " and (wr_num between '".$spt."' and '".($spt + $config[cf_search_part])."') ";	// and wr_9 != 'SELL' ";
	}
	    // 원글만 얻는다. (코멘트의 내용도 검색하기 위함)
	    $sql = " select distinct wr_parent from $write_table where $sql_search ";
	    $result = sql_query($sql);
	    $total_count = mysql_num_rows($result);
}
else
{
    //$sql_search = " wr_9 != 'SELL' ";
    $sql_search = " ";

    $total_count = $board['bo_count_write'];
}

$total_page  = ceil($total_count / $page_row);  // 전체 페이지 계산
if (!$page) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
//$from_record = ($page - 1) * $page_row; // 시작 열을 구함
$from_record = $board['bo_page_rows'] + ($page - 2) * $page_row; // 시작 열을 구함

// 정렬에 사용하는 QUERY_STRING
$qstr2 = "bo_table=g4_board&sop=$sop";

if (!$sst)
{
    if ($board['bo_sort_field'])
        $sst = $board['bo_sort_field'];
    else
        $sst  = "wr_num, wr_reply";
    $sod = "";
}
else {
    // 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16)
    // 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요.
    // $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
    $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";
}

if ($sst)
    $sql_order = " order by $sst $sod ";

if ($sca || $stx || $bo_gubun)
{
    $sql = " select distinct wr_parent from $write_table where $sql_search $sql_order limit $from_record, $page_row " ;
}
else
{
    //$sql = " select *, CASE WHEN TIMESTAMPDIFF(MINUTE, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(SECOND, wr_datetime, now()),'초전') WHEN TIMESTAMPDIFF(HOUR, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(MINUTE, wr_datetime, now()),'분전') WHEN TIMESTAMPDIFF(DAY, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(HOUR, wr_datetime, now()),'시간전') ELSE concat(TIMESTAMPDIFF(DAY, wr_datetime, now()),'일전') END diff from $write_table where wr_is_comment = 0 and wr_9 != 'SELL' $sql_order limit $from_record, $page_row ";
    $sql = " select *, CASE WHEN TIMESTAMPDIFF(MINUTE, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(SECOND, wr_datetime, now()),'초전') WHEN TIMESTAMPDIFF(HOUR, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(MINUTE, wr_datetime, now()),'분전') WHEN TIMESTAMPDIFF(DAY, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(HOUR, wr_datetime, now()),'시간전') ELSE concat(TIMESTAMPDIFF(DAY, wr_datetime, now()),'일전') END diff, (select count(*) from g4_scrap s where s.bo_table = '$table_gubun' and s.wr_id = $write_table.wr_id and mb_id = '$mb_id') as scrap_cnt from $write_table where wr_is_comment = 0 $sql_order limit $from_record, $page_row ";
}
//echo $sql;
$result = sql_query($sql);

// 년도 2자리
$today2 = $g4[time_ymd];

$list = array();
$i = 0;

if (!$sca && !$stx && !$bo_gubun)
{
    $arr_notice = explode("\n", trim($board['bo_notice']));
    for ($k=0; $k<count($arr_notice); $k++)
    {
        if (trim($arr_notice[$k])=='') continue;

        $row = sql_fetch(" select *, CASE WHEN TIMESTAMPDIFF(MINUTE, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(SECOND, wr_datetime, now()),'초전') WHEN TIMESTAMPDIFF(HOUR, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(MINUTE, wr_datetime, now()),'분전') WHEN TIMESTAMPDIFF(DAY, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(HOUR, wr_datetime, now()),'시간전') ELSE concat(TIMESTAMPDIFF(DAY, wr_datetime, now()),'일전') END diff, (select count(*) from g4_scrap s where s.bo_table = '$table_gubun' and s.wr_id = $write_table.wr_id and mb_id = '$mb_id') as scrap_cnt from $write_table where wr_id = '$arr_notice[$k]' $sql_order ");

        if (!$row[wr_id]) continue;

        $list[$i] = get_list($row, $board, $board_skin_path, $board['bo_subject_len']);
        $list[$i][is_notice] = true;
        
        //댓글추가
        $sql = " select *,(select case when (a.mb_icon is null or a.mb_icon = '') and mb_sex='F' then '/img/product/icon_people1.gif' when (a.mb_icon is null or a.mb_icon = '') then '/img/product/icon_people.gif' else a.mb_icon end from g4_member a where a.mb_id = b.mb_id) as mb_icon, (select count(*) from $write_table a where b.wr_id = a.family) as family_cnt  from $write_table b where wr_parent = '{$list[$i]['wr_id']}' and wr_is_comment = 1 order by orderby desc ";
		$result_arr = sql_query($sql);
		
		$list[$i]['result_arr'] = $result_arr;
		
        $i++;
    }
}

$k = 0;

while ($row = sql_fetch_array($result))
{
    // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다
    if ($sca || $stx || $bo_gubun)
        $row = sql_fetch(" select *, CASE WHEN TIMESTAMPDIFF(MINUTE, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(SECOND, wr_datetime, now()),'초전') WHEN TIMESTAMPDIFF(HOUR, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(MINUTE, wr_datetime, now()),'분전') WHEN TIMESTAMPDIFF(DAY, wr_datetime, now()) < 1 THEN concat(TIMESTAMPDIFF(HOUR, wr_datetime, now()),'시간전') ELSE concat(TIMESTAMPDIFF(DAY, wr_datetime, now()),'일전') END diff, (select count(*) from g4_scrap s where s.bo_table = '$table_gubun' and s.wr_id = $write_table.wr_id and mb_id = '$mb_id') as scrap_cnt from $write_table where wr_id = '$row[wr_parent]' $sql_order ");

    $list[$i] = get_list($row, $board, $board_skin_path, $board['bo_subject_len']);
    if (strstr($sfl, "subject"))
        $list[$i][subject] = search_font($stx, $list[$i][subject]);
    $list[$i][is_notice] = false;
    
    //댓글추가
	$sql = " select *,(select case when (a.mb_icon is null or a.mb_icon = '') and mb_sex='F' then '/img/product/icon_people1.gif' when (a.mb_icon is null or a.mb_icon = '') then '/img/product/icon_people.gif' else a.mb_icon end from g4_member a where a.mb_id = b.mb_id) as mb_icon, (select count(*) from $write_table a where b.wr_id = a.family) as family_cnt   from $write_table b where wr_parent = '{$list[$i]['wr_id']}' and wr_is_comment = 1 order by orderby desc ";
	$result_arr = sql_query($sql);
	
	$list[$i]['result_arr'] = $result_arr;
		
    //$list[$i][num] = number_format($total_count - ($page - 1) * $board[bo_page_rows] - $k);
    $list[$i][num] = $total_count - ($page - 1) * $board['bo_page_rows'] - $k;

    $i++;
    $k++;
}

if(count($list) < 1){
	echo "0";
}else{
	echo "\n	<table cellspacing=\"0\" cellpadding=\"0\" class=\"board_list\">";
	for ($i=0; $i<count($list); $i++) {
		$bg = $i%2 ? 0 : 1;
		?>

<? if (1==2 && ($i==0 || substr($list[$i][wr_datetime],0,10) != substr($list[$i-1][wr_datetime],0,10)) ){?>
    <tr>
		<td>
			<div >
				<div style="width:101px; margin:0 auto;">
					<div style="height:55px; border-bottom:1px solid #dbdbdb; text-align:center;margin:0;margin-bottom:4px;"><img src="/img/comm/num_0<?=substr($list[$i][wr_datetime],8,1)?>.jpg" alt="" /> <img src="/img/comm/num_0<?=substr($list[$i][wr_datetime],9,1)?>.jpg" alt="" /> </div>
					<div style="overflow:hidden;">
						<div style="float:left;"><img src="/img/comm/mon_<?=substr($list[$i][wr_datetime],5,2)?>.jpg" alt="" /></div>
						<div style="float:right;"><img src="/img/comm/year_<?=substr($list[$i][wr_datetime],0,4)?>.jpg" alt="" /></div>
					</div>
				</div>
			</div>
		</td>
	</tr>
<?}?>
		
		<?
		echo "\n	<tr class=\"list_".$list[$i][wr_id]."\">";
		echo "\n		<td height=\"1\" bgcolor=\"DCDCDC\"></td>";
		echo "\n	</tr>";
		echo "\n	<tr class=\"list_".$list[$i][wr_id]."\">";
		echo "\n		<td height=\"40\">";
		echo "\n			<table width=\"675\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >";
		echo "\n				<tr>";
		echo "\n					<td width=\"280\" class=\"txt14\">".$list[$i][ca_name_1]." &gt; <span class=\"txt18_point\">".$list[$i][ca_name_2]."</span></td>";
		echo "\n					<td width=\"170\" align=\"right\" class=\"txt14\">";
		
		$imggubun = "01";
		if($write_table == "g4_write_sellitem"){
			if($list[$i][mb_id] == $mb_id){
				if($list[$i][wr_9]!='SELL'){
					echo "\n					<a href=\"javascript:goReUpload('".$list[$i][wr_id]."',1, '".$list[$i][wr_datetime]."');\"><img src=\"../img/product/bt_re_up.gif\" align=\"middle\" /></a><a href=\"javascript:goReUpload('".$list[$i][wr_id]."',2,'');\"><img src=\"../img/product/bt_complete.gif\" align=\"middle\" /></a>";
				}else{
					echo "\n					판매완료상품";
				}
			}
		}else{
			$imggubun = "02";
			echo "\n					&nbsp;";
		}
		echo "\n					</td>";
		echo "\n					<td width=\"169\" align=\"center\" class=\"txt14\">";
		echo "\n						By ".$list[$i][name_sub]."&nbsp;<img src=\"{$list[$i][mb_icon]}\" width=\"22\" height=\"23\" align=\"absmiddle\" />&nbsp;";
		echo "\n					</td>";
		echo "\n					<td width=\"56\">";
		echo "\n						<div style=\"width:56px; height:19px; background:url('../img/product/days".$imggubun."_bg.gif') no-repeat; color:#fff; font-size:12px;text-align:center;padding-top:3px;\">";
		echo "\n							".$list[$i][diff];
		echo "\n						</div>";
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n			</table>";
		echo "\n		</td>";
		echo "\n	</tr>";
		echo "\n	<tr class=\"list_".$list[$i][wr_id]."\">";
		echo "\n		<td valign=\"top\">";
		echo "\n			<table width=\"675\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		echo "\n				<tr>";
		echo "\n					<td width=\"215\" rowspan=\"3\" valign=\"top\">";
		echo "\n						<table width=\"183\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		echo "\n							<tr>";
		echo "\n								<td colspan=\"4\">";
		echo "\n									<table border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n										<tr>";
		echo "\n											<td>";
		if (!$list[$i][file][0]){
			echo "\n											<img src=\"/img/noImage183x136.gif\" width=\"183\" height=\"136\" class='bigImg'/>";
		} else {
			echo "\n											<a href=\"javascript:\"><img src=\"".$list[$i][file][0][path]."/".$list[$i][file][0][file]."\" width=\"183\" height=\"136\" class='bigImg imgClass'/></a>";
		}
		echo "\n											</td>";
		echo "\n										</tr>";
		echo "\n									</table>";
		echo "\n								</td>";
		echo "\n							</tr>";
		echo "\n							<tr>";
		echo "\n								<td>";
		echo "\n									<table border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n										<tr>";
		echo "\n											<td>";
		if ($list[$i][file][0]){
			echo "\n											<a href=\"javascript:imgChange(".$i.",'".$list[$i][file][0][path]."/".$list[$i][file][0][file]."');\"><img src='".$list[$i][file][0][path]."/".$list[$i][file][0][file]."' align='absmiddle' border='0' width='42' height='34'></a>";
		} else {
			echo "\n											<img src=\"/img/noImage183x136.gif\" width=\"42\" height=\"34\" />";
		}
		echo "\n											</td>";
		echo "\n										</tr>";
		echo "\n									</table>";
		echo "\n								</td>";
		echo "\n								<td height=\"44\">";
		echo "\n									<table border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n										<tr>";
		echo "\n											<td>";
		if ($list[$i][file][1]){
			echo "\n											<a href=\"javascript:imgChange(".$i.",'".$list[$i][file][1][path]."/".$list[$i][file][1][file]."');\"><img src='".$list[$i][file][1][path]."/".$list[$i][file][1][file]."' align='absmiddle' border='0' width='42' height='34'></a>";
		} else {
			echo "\n											<img src=\"/img/noImage183x136.gif\" width=\"42\" height=\"34\" />";
		}
		echo "\n											</td>";
		echo "\n										</tr>";
		echo "\n									</table>";
		echo "\n								</td>";
		echo "\n								<td>";
		echo "\n									<table border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n										<tr>";
		echo "\n											<td>";
		if ($list[$i][file][2]){
			echo "\n											<a href=\"javascript:imgChange(".$i.",'".$list[$i][file][2][path]."/".$list[$i][file][2][file]."');\"><img src='".$list[$i][file][2][path]."/".$list[$i][file][2][file]."' align='absmiddle' border='0' width='42' height='34'></a>";
		} else {
			echo "\n											<img src=\"/img/noImage183x136.gif\" width=\"42\" height=\"34\" />";
		}
		echo "\n											</td>";
		echo "\n										</tr>";
		echo "\n									</table>";
		echo "\n								</td>";
		echo "\n								<td>";
		echo "\n									<table border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n										<tr>";
		echo "\n											<td>";
		if ($list[$i][file][3]){
			echo "\n											<a href=\"javascript:imgChange(".$i.",'".$list[$i][file][3][path]."/".$list[$i][file][3][file]."');\"><img src='".$list[$i][file][3][path]."/".$list[$i][file][3][file]."' align='absmiddle' border='0' width='42' height='34'></a>";
		} else {
			echo "\n											<img src=\"/img/noImage183x136.gif\" width=\"42\" height=\"34\" />";
		}
		echo "\n											</td>";
		echo "\n										</tr>";
		echo "\n									</table>";
		echo "\n								</td>";
		echo "\n							</tr>";
		echo "\n						</table>";
		echo "\n					</td>";
		echo "\n					<td width=\"460\">";
		echo "\n						<table width=\"460\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		echo "\n							<tr>";
		echo "\n								<td width=\"33%\" height=\"67\"><span class=\"txt14\">".$list[$i][itemBrand]."</span></td>";
		echo "\n								<td width=\"33%\" align=\"center\"><span class=\"txt14\">".$list[$i][itemName]."</span></td>";
		echo "\n								<td width=\"33%\" align=\"right\"><span class=\"txt14\">".han_price($list[$i][itemPrice])."</span></td>";
		echo "\n							</tr>";
		echo "\n						</table>";
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n				<tr>";
		echo "\n					<td>";
		echo "\n						<table width=\"460\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		echo "\n							<tr>";
		echo "\n								<td width=\"393\" height=\"23\" class=\"txt14_g\">".$list[$i][wr_area]."</td>";
		echo "\n								<td width=\"87\" class=\"txt14_g\">";
		$wr_1_checked = "";
		if($list[$i][wr_1]){
			$wr_1_checked = "checked=\"checked\"";
		}
		echo "\n									<input type=\"checkbox\" name=\"checkbox\" id=\"checkbox\" disabled=\"disabled\" ".$wr_1_checked." />직거래";
		echo "\n								</td>";
		echo "\n							</tr>";
		echo "\n							<tr>";
		$wr_2_checked = "";
		if($list[$i][wr_2]){
			$wr_2_checked = "checked=\"checked\"";
		}
		$wr_10_value = "";
		if($list[$i][wr_10]){
			$wr_10_value = "#".$list[$i][wr_10];
		}
		echo "\n								<td height=\"23\" class=\"txt14_g\">".$wr_10_value."</td>";
		echo "\n								<td class=\"txt14_g\">";
		echo "\n									<input type=\"checkbox\" name=\"checkbox2\" id=\"checkbox2\" disabled=\"disabled\" ".$wr_2_checked." />택배";
		echo "\n								</td>";
		echo "\n							</tr>";
		echo "\n						</table>";
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n				<tr>";
		echo "\n					<td valign=\"bottom\" align=\"right\">&nbsp;";
		
		if ($mb_id){
	    	if ($list[$i][mb_id] == $mb_id) {
	    		if($list[$i]['wr_9'] != "SELL"){
	    			echo "\n				<img src=\"../img/product/bt_modify.gif\" align=\"absmiddle\" style=\"cursor:pointer;\" onclick=\"javascript:goModify(".$list[$i][wr_id].");\" />";
	    			echo "\n				<img src=\"../img/product/bt_del.gif\" align=\"absmiddle\" style=\"cursor:pointer;\" onclick=\"javascript:goDelete(".$list[$i][wr_id].");\" />";
	    		}
	    	}else{ 
				if($list[$i]['scrap_cnt'] == "0"){
	   				echo "\n				<div id=\"scripView_".$list[$i][wr_id]."\">";
					echo "\n					<img src=\"../img/product/bt_plus.gif\" width=\"93\" height=\"22\" style=\"cursor:pointer;\" onclick=\"javascript:goScrap(".$list[$i][wr_id].");\" />";
					echo "\n				</div>";
				}else{
					echo "\n				<div id=\"scripView_".$list[$i][wr_id]."\">";
					echo "\n					<img src=\"../img/product/bt_minus.gif\" width=\"93\" height=\"22\" style=\"cursor:pointer;\" onclick=\"javascript:goScrapDel(".$list[$i][wr_id].");\" />";
					echo "\n				</div>";
				}
	    	}
		}
    	
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n			</table>";
		echo "\n		</td>";
		echo "\n	</tr>";
		echo "\n	<tr class=\"divDetail list_".$list[$i][wr_id]."\" style=\"display:none\">";
		echo "\n		<td>";
		echo "\n			<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
		echo "\n				<tr>";
		echo "\n					<td colspan=\"2\">";
		echo "\n						<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bordercolor=\"D9D9D9\" bgcolor=\"D9D9D9\">";
		echo "\n							<tr>";
		echo "\n								<td bgcolor=\"#FFFFFF\">".str_replace("\n","<br>", $list[$i][wr_content])."</td>";
		echo "\n							</tr>";
		echo "\n						</table>";
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n				<tr height=\"10\">";
		echo "\n					<td colspan=\"2\"></td>";
		echo "\n				</tr>";
		echo "\n			<tr height=\"27px;\"> ";
		if($list[$i][wr_5] != "1"){
			echo "\n				<td><strong>연락처</strong> : {$list[$i][wr_3]} </td> ";
		}		
		echo "\n				<td align=\"right\"> ";
		echo "\n					<a href=\"javascript:;\" onclick=\"sSNS('twitter', '', '".str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])."');\"><img src=\"../img/home/btn_tweeter.gif\" style=\"vertical-align:middle;\" /></a> ";
		echo "\n					<a href=\"javascript:;\" onclick=\"sSNS('me2day', '', '".str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])."');\"><img src=\"../img/home/btn_me2day.gif\" style=\"vertical-align:middle;\" /></a> ";
		echo "\n					<a href=\"javascript:;\" onclick=\"sSNS('facebook', '', '".str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])."');\"><img src=\"../img/home/btn_facebook.gif\" style=\"vertical-align:middle;\" /></a> ";
		echo "\n					<a href=\"javascript:;\" onclick=\"sSNS('cyworld', '', '".str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])."');\"><img src=\"../img/home/btn_cyworld.gif\" style=\"vertical-align:middle;\" /></a> ";
		echo "\n				</td> ";
		echo "\n			</tr> ";
		echo "\n			<tr> ";
		echo "\n				<td colspan=\"2\"><strong>이메일</strong> : {$list[$i][wr_4]} </td> ";
		echo "\n			</tr> ";
		echo "\n				<tr>";
		echo "\n					<td colspan=\"2\">&nbsp;</td>";
		echo "\n				</tr>";
		$re_cnt = "0";
		if($list[$i]['comment_cnt'] != 0){
			$re_cnt = $list[$i]['comment_cnt'];
		}
		echo "\n				<tr height=\"30px;\">";
		echo "\n					<td colspan=\"2\"><strong>댓글(<span id=\"re_".$list[$i][wr_id]."\">".$re_cnt."</span>)개</strong></td>";
		echo "\n				</tr>";
		echo "\n				<tr>";
		echo "\n					<td colspan=\"2\">";
		echo "\n						<div id=\"table_{$list[$i][wr_id]}\"> ";
		echo "\n						<table>";
		if(!$list[$i]['result_arr']){
			echo "\n						<tr>";
			echo "\n							<td>&nbsp;</td>";
			echo "\n						</tr>";
		}
		for ($j=0; $row=sql_fetch_array($list[$i]['result_arr']); $j++) {
			$name_sub_arr = get_sideview_sub($row['mb_id'], $row['wr_name'], $row['wr_email'], $row['wr_homepage']);
			echo "\n						<tr id=\"".$list[$i][wr_id]."_".$row['wr_id']."\">";
			echo "\n							<td>";
			
			if(intval($row['step']) > 1){
					echo "&nbsp;&nbsp;&nbsp;&nbsp;";
					echo "				<img src=\"../img/product/icon_re.gif\" width=\"17\" height=\"11\" hspace=\"3\" vspace=\"3\" align=\"absmiddle\" /> ";
			}
				
			echo "\n								".$name_sub_arr."<img src=\"{$row['mb_icon']}\" width=\"22\" height=\"23\" align=\"absmiddle\" />";
			echo "\n								&nbsp;&nbsp;&nbsp;&nbsp;".$row['wr_content'];
			if($mb_id){
			echo "\n								&nbsp;&nbsp;<img src=\"../img/product/bt_re.gif\" style=\"cursor:pointer;\" onclick=\"javascript:showContent('{$list[$i][wr_id]}_{$row['wr_id']}');\" width=\"40\" height=\"19\" vspace=\"2\" align=\"absmiddle\" />";
			}
			if($mb_id == $row['mb_id'] || $is_admin == "super" || $is_auth){
				echo "\n							&nbsp;&nbsp;<img src=\"../img/product/bt_del.gif\" style=\"cursor:pointer;\" onclick=\"javascript:deleteContent('".$list[$i][wr_id]."', '".$row['wr_id']."', '{$row['step']}', '{$row['family_cnt']}');\" width=\"40\" height=\"19\" vspace=\"2\" align=\"absmiddle\" />";
			}
			echo "\n							</td>";
			echo "\n						</tr>";
			echo "\n						<tr id=\"{$list[$i][wr_id]}_{$row['wr_id']}_content\" style=\"display:none\"> ";
			echo "\n							<td> ";
			echo "\n								<input type=\"text\" name=\"re_content_{$list[$i][wr_id]}_{$row['wr_id']}\" id=\"re_content_{$list[$i][wr_id]}_{$row['wr_id']}\" size=\"110\" /> ";
			echo "\n								<img src=\"../img/product/bt_enter.gif\" style=\"cursor:pointer;\" onclick=\"javascript:writeContent('{$list[$i][wr_id]}', '{$row['wr_id']}', '{$row['orderby']}', '{$row['step']}');\" width=\"46\" height=\"22\" align=\"absmiddle\" /> ";
			echo "\n							</td> ";
			echo "\n						</tr> ";
		}
		echo "\n						</table>";
		echo "\n						</div>";
		echo "\n					</td>";
		echo "\n				</tr>";
		echo "\n				<tr>";
		echo "\n					<td colspan=\"2\">&nbsp;</td>";
		echo "\n				</tr>";
		if($mb_id){
			echo "\n			<tr>";
			echo "\n				<td colspan=\"2\">";
			echo "\n					<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "\n						<tr>";
			echo "\n							<td><strong>댓글</strong></td>";
			echo "\n							<td align=\"center\"><input type=\"text\" name=\"re_content_".$list[$i][wr_id]."_0\" id=\"re_content_".$list[$i][wr_id]."_0\" size=\"110\" /></td>";
			echo "\n							<td><img src=\"../img/product/bt_enter.gif\" style=\"cursor:pointer;\" onclick=\"javascript:writeContent('".$list[$i][wr_id]."', '0', '0', '0');\" width=\"46\" height=\"22\" align=\"absmiddle\" /></td>";
			echo "\n						</tr>";
			echo "\n					</table>";
			echo "\n				</td>";
			echo "\n			</tr>";
		}
		echo "\n			</table>";
		echo "\n		</td>";
		echo "\n	</tr>";
		echo "\n	<tr class=\"list_".$list[$i][wr_id]."\"><td height=\"30\" colspan=\"2\" align=\"center\">";
		//echo "\n		<td height=\"30\" colspan=\"2\" align=\"center\"><a href=\"javascript:showDetail(".(intval($from_record)+$i).")\"><span class=\"spanDiv\" class=\"txt14_g\">더보기</span></a></td>";
		echo "\n		<p style=\"padding-bottom:5px;\"><img id=\"spanDiv_".($from_record+$i)."\" style=\"cursor:pointer;\" src=\"../img/product/btn_up.gif\" style=\"vertical-align:middle;\" onclick=\"javascript:showDetail(".($from_record+$i).")\" /></p>";
		echo "\n	</td></tr>";
	}
	echo "\n	</table>";
	echo "\n	<div style=\"padding:20px 0;text-align:center;border: 1\">";
	echo "\n		<img src=\"/img/banner/banner.jpg\" width=\"90%\" height=\"100%\"/>";
	echo "\n	</div>";
}

?>